package org.codeart.factory.scheme02.factory;

import org.codeart.factory.scheme02.service.IFreeGoods;
import org.codeart.factory.scheme02.service.impl.DiscountFreeGoods;
import org.codeart.factory.scheme02.service.impl.GiftFreeGoods;
import org.codeart.factory.scheme02.service.impl.VideoVipFreeGoods;

/**
 * 简单工厂模式
 * 静态工厂模式
 */
public class FreeGoodsFactory {

    public static IFreeGoods produceFreeGoods(Integer type) {
        IFreeGoods goods = null;
        if (type == 1) {
            goods = new DiscountFreeGoods();
        } else if (type == 2) {
            goods = new VideoVipFreeGoods();
        } else if (type == 3) {
            goods = new GiftFreeGoods();
        }
        return goods;
    }

}
